#!/bin/bash -ex

git clone --depth 1 https://github.com/endrazine/wcc
pushd wcc
git submodule init
git submodule update

# fedora doesn't have stropts.h since apparently it's unsupported on linux
# anyway. wcc compiles fines without it.
if [[ "$DISTRI" == "fedora" ]]; then
    sed -i "s&#include <stropts.h>&/*#include <stropts.h>*/&g" \
        src/wsh/include/libwitch/wsh.h
fi


make
mv bin/ ../
popd
pushd bin/
sed -i "s&/usr/bin/wsh&$(pwd)/wsh&" ./wcch
